<ix-modal-header
  [requiredRoles]="requiredRoles"
  [title]="'Capacity Settings' | translate"
  [loading]="isLoading()"
></ix-modal-header>
<mat-card>
  <mat-card-content>
    <form class="ix-form-container" [formGroup]="form" (submit)="onSubmit()">
      @if (dataset) {
        <div class="columns">
          <div class="column">
            <ix-fieldset [title]="'This Dataset' | translate">
              <ix-input
                formControlName="refquota"
                [label]="'Quota for this dataset' | translate"
                [tooltip]="helptext.refquotaTooltip | translate"
                [format]="formatter.memorySizeFormatting"
                [parse]="formatter.memorySizeParsing"
              ></ix-input>

              <div class="refquota-warning-fields">
                <ix-input
                  formControlName="refquota_warning"
                  type="number"
                  [label]="'Quota warning alert at, %' | translate"
                ></ix-input>

                <ix-checkbox
                  formControlName="refquota_warning_inherit"
                  class="inherit-field"
                  [label]="isRoot ? ('Default' | translate) : ('Inherit' | translate)"
                  [tooltip]="helptext.refquotaWarningTooltip | translate"
                ></ix-checkbox>
              </div>

              <div class="refquota-critical-fields">
                <ix-input
                  formControlName="refquota_critical"
                  type="number"
                  [label]="'Quota critical alert at, %' | translate"
                ></ix-input>

                <ix-checkbox
                  formControlName="refquota_critical_inherit"
                  class="inherit-field"
                  [label]="isRoot ? ('Default' | translate) : ('Inherit' | translate)"
                  [tooltip]="helptext.refquotaCriticalTooltip | translate"
                ></ix-checkbox>
              </div>

              <ix-input
                formControlName="refreservation"
                [label]="'Reserved space for this dataset' | translate"
                [tooltip]="helptext.refreservationTooltip | translate"
                [format]="formatter.memorySizeFormatting"
                [parse]="formatter.memorySizeParsing"
              ></ix-input>
            </ix-fieldset>
          </div>
          <div class="column">
            <ix-fieldset [title]="'This Dataset and Child Datasets' | translate">
              <ix-input
                formControlName="quota"
                [label]="'Quota for this dataset and all children' | translate"
                [tooltip]="helptext.quotaTooltip | translate"
                [format]="formatter.memorySizeFormatting"
                [parse]="formatter.memorySizeParsing"
              ></ix-input>

              <div class="quota-warning-fields">
                <ix-input
                  formControlName="quota_warning"
                  type="number"
                  [label]="'Quota warning alert at, %' | translate"
                ></ix-input>

                <ix-checkbox
                  formControlName="quota_warning_inherit"
                  class="inherit-field"
                  [label]="isRoot ? ('Default' | translate) : ('Inherit' | translate)"
                  [tooltip]="helptext.quotaWarningTooltip | translate"
                ></ix-checkbox>
              </div>

              <div class="quota-critical-fields">
                <ix-input
                  formControlName="quota_critical"
                  type="number"
                  [label]="'Quota critical alert at, %' | translate"
                ></ix-input>

                <ix-checkbox
                  formControlName="quota_critical_inherit"
                  class="inherit-field"
                  [label]="isRoot ? ('Default' | translate) : ('Inherit' | translate)"
                  [tooltip]="helptext.quotaCriticalTooltip | translate"
                ></ix-checkbox>
              </div>
              <ix-input
                formControlName="reservation"
                [label]="'Reserved space for this dataset and all children' | translate"
                [tooltip]="helptext.reservationTooltip | translate"
                [format]="formatter.memorySizeFormatting"
                [parse]="formatter.memorySizeParsing"
              ></ix-input>
            </ix-fieldset>
          </div>
        </div>
      }

      <ix-form-actions>
        <button
          *ixRequiresRoles="requiredRoles"
          mat-button
          type="submit"
          color="primary"
          ixTest="save"
          [disabled]="form.invalid || isLoading()"
        >
          {{ 'Save' | translate }}
        </button>
      </ix-form-actions>
    </form>
  </mat-card-content>
</mat-card>
